//
//  MDIOAutoVC.swift
//  
//
//  Created by 迁徙鸟 on 16/4/18.
//
//

import UIKit

class MDIOAutoVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = UIColor.grayColor()
        
        setNav()
    }

    override func loadView() {
        
        view = webView
        let url = NSURL(string: "https://api.weibo.com/oauth2/authorize?client_id=\(APPKEY)&redirect_uri=\(REDIRECT_URI)")
        
    
        let requ = NSURLRequest(URL: url!)
        
        webView.loadRequest(requ)
        
    }
    
//    MARK - 设置导航栏
    private func setNav(){
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "取消", style: UIBarButtonItemStyle.Plain, target: self, action: "cancle")
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "自动填充", style: UIBarButtonItemStyle.Plain, target: self, action: "auto")
    
    navigationItem.title = "微博登录"
    }
    
//    MARK - 实现点击方法
    
    @objc private func cancle(){
    
    dismissViewControllerAnimated(true, completion: nil)
    }
    
    @objc private func auto(){
        
        print("自动填充")
    }

//    懒加载UIWeb
    private lazy var webView: UIWebView = UIWebView()
    
    
    
    
    
    
    }
